﻿@model BrnMall.Web.StoreAdmin.Models.SendOrderProductModel

@section header{
    <title>发货</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css"/>
    <script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_store/scripts/jquery.validate.unobtrusive.js"></script>
    <link rel="stylesheet" type="text/css" href="/components/jbox/Skins/Default/jbox.css" />
    <script type="text/javascript" src="/components/jbox/jquery.jBox-2.3.min.js"></script>
}

@section body{
<h1 class="rightH1">
	微信小程序 &gt; 订单管理 &gt; <span class="rightH1-cur">发货</span>
<div class="right">
<a href="@Url.Action("orderinfo", new { oid = ((OrderInfo)ViewData["orderInfo"]).Oid })" class="menuBT"><img src="/admin_store/images/goback.jpg"/>返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>
@using (Html.BeginForm())
{
<div class="addTable">
<table width="100%">
    <tr>
        <td width="80px" align="right">发货公司：</td>
        <td>@Html.DropDownListFor(x => x.ShipCoId, ViewData["shipCompanyList"] as List<SelectListItem>) @Html.ValidationMessageFor(x => x.ShipCoId)</td>
    </tr>
    <tr class="ShipSN">
        <td align="right">发货单号：</td>
        <td>@Html.TextBoxFor(x => x.ShipSN, new { @class = "input", size = "20" })@Html.ValidationMessageFor(x => x.ShipSN)</td>
    </tr>
    <tr>
        <td colspan="2" class="ship hide" style="padding-left:30px; line-height:30px;">
            <div>配送地址：<span class="ShipAddress"></span> （<span class="ShipDistance">0</span> 公里）</div>
            <div>配送费用：<span class="ShipFee">0</span> 元</div>
        </td>
    </tr>
    <tr>
        <td align="right">&nbsp;</td>
        <td>
            <a href="" class="addBt" id="sumbitBut"><img src="/admin_store/images/submit.jpg" /></a> 
        </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
<script type="text/javascript">
    $(function () {

        $("#sumbitBut").click(function () {
            $("form:first").submit();
            return false;
        })

        $("#ShipCoId").change(function () {
            var text = $("#ShipCoId").find("option:selected").text();

            if (text.indexOf("达达") > -1) {
                loadShip();
            }
            else {
                $(".ship").addClass("hide");       //隐藏达达配送
                $(".ShipSN").removeClass("hide");
                if ($("#ShipSN").val() == "未填")
                    $("#ShipSN").val("");
            }
        })
    });

     //加载配送价格
    function loadShip() {
        //接口
        var url = "http://weapp.711688.net.cn/api/ship/GetshipFee?oid=@Request["oid"]";
        $.get(url, "", function (data) {
            if (data.Code != 0) {
                $.jBox.tip(data.Message);  //错误消息
                return;
            }

            var item = data.Data;
            $(".ShipFee").html(item.ShipFee);
            $(".ShipDistance").html(parseFloat(item.ShipDistance) * 0.001);
            $(".ShipAddress").html(item.ShipAddress);

            $("#ShipSN").val("未填");
            $(".ShipSN").addClass("hide")
            $(".ship").removeClass("hide");    //显示达达配送费用
        });
    }
 </script>
}
}
